import { createRouter, createWebHistory } from 'vue-router'


const routes = [
    {
        path: '/',
        redirect: '/detail'
    },
    {
        path: '',
        redirect: '/detail'
    },
    {
        path: '/detail',
        name: 'detail',
        meta:{title:'详情页'},
        component: () => (import('@/views/Detail.vue'))
    },
    {
        path: '/insert',
        name: 'insert',
        meta:{title:'新增页'},
        component: () => (import('@/views/Insert.vue'))
    },
    {
        path: '/edit/:id',
        name: 'edit',
        meta:{title:'编辑页'},
        component: () => (import('@/views/Edit.vue'))
    }
    //404
    /*{
        path: '/:path(.*)',
        meta:{title:'Error 404'},
        component: () => (import('@/pages/NotFind.vue'))
    }*/
]

const router = createRouter({
    history: createWebHistory(),
    routes
})
router.beforeEach((to, from, next) => {

    next(); // 继续路由跳转
});
router.afterEach((to,from)=>{
    document.title = to.meta.title || '佚名';
})
export default router
